package com.boarsoft.boar.batch.demo.flow.demo;

import com.boarsoft.boar.batch.bean.BatchExecCtrlFlag;
import com.boarsoft.boar.batch.entity.BatchExecution;
import com.boarsoft.boar.batch.service.BatchReportService;
import com.boarsoft.common.util.InetUtil;
import com.boarsoft.flow.core.bean.ProcessHandler;
import com.boarsoft.hibernate.biz.SimpleBizImpl;
import com.boarsoft.hibernate.dao.SimpleDao;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 生成文件
 *
 * @author wangtao
 */
public class DemoProcess3HD extends SimpleBizImpl implements ProcessHandler {

    @Autowired
    private SimpleDao simpleDao;

    @Autowired
    private BatchReportService batchReportService;

    @Override
    public Object process(String entry, Object data, Throwable throwable) throws Throwable {
        System.out.println(" do DemoProcess3HD...");
        short intdStatus = BatchExecCtrlFlag.getStatus("intdNo");
        for(int i=0; i<1000; i++){
            //暂停或取消状态
            if(intdStatus == BatchExecution.STATUS_STOPPED || intdStatus == BatchExecution.STATUS_CANCELED){
                //return
                //new Exception
                //根据业务场景需要看是否需要再次单独识别暂停和取消（主要体现为登记流水表）
            }
            System.out.println(" 生成薪资变更下载文件开始");
            //more code here
            System.out.println(" 生成薪资变更下载文件完成");
        }

        /**
         * 进度上报，预期完成当前阶段的占比
         */
//        batchReportService.report("123456", "+10", "DemoProcess3HD", InetUtil.getIp());
        return true;
    }
}
